package com.itzdm.ws.controller;

import com.itzdm.client.domain.po.Message;
import com.itzdm.ws.config.WebSocketSingleServer;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @作者：张德明
 * @时间：2025/4/16 20:58
 */
@RestController
@RequiredArgsConstructor
@Slf4j
public class WsController {
//    @PostMapping("/websocket/send")
//    void sendMsg(Long userId, Message message);

    @PostMapping("/send")
    public void sendMessage(Long userId, @RequestBody Message message) {
        WebSocketSingleServer.sendMessage(userId,message);
    }

    @PostMapping("/sendMessage")
    public void sendMessage(Long friendId, String message){
        WebSocketSingleServer.sendMessage(friendId,message);
    }
}
